package com.example.chat.controller;

import com.example.chat.pojo.dto.FriendDTO;
import com.example.chat.pojo.res.ResModel;
import com.example.chat.service.FriendService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 林邵晨
 * @since 2023-07-24
 */
@RestController
@RequestMapping("/chat/friend")
public class FriendController {

    @Autowired
    private FriendService friendService;

    @ApiOperation("查询好友列表")
    @GetMapping(path = "/list/{cid}",produces = "application/json")
    public ResModel listByCid(@PathVariable String cid){
        return friendService.listByCid(cid);
    }

    @ApiOperation("删除好友")
    @PostMapping(path = "/delete",produces = "application/json")
    public ResModel deleteFriend(@RequestBody FriendDTO friendDTO){
        return friendService.deleteFriend(friendDTO);
    }

    @ApiOperation("添加星标好友")
    @PostMapping(path = "/add/star",produces = "application/json")
    public ResModel addStarFriend(@RequestBody FriendDTO friendDTO){
        return friendService.addStarFriend(friendDTO);
    }

    @ApiOperation("取消星标好友")
    @PostMapping(path = "/cancel/star",produces = "application/json")
    public ResModel cancelStarFriend(@RequestBody FriendDTO friendDTO){
        return friendService.cancelStarFriend(friendDTO);
    }

    @ApiOperation("查询聊天列表")
    @GetMapping(path = "/list/chat/{cid}",produces = "application/json")
    public ResModel chatListByCid(@PathVariable String cid){
        return friendService.chatListByCid(cid);
    }
}
